import {getSubject, getTeacherList, addTeacher, getOneTeacher, editOneTeacher, delOneTeacher, importTeacher, exportExcel, changeStatus} from '@/api/teacherApi'
import {getClassList, getDept} from '@/api/baseDataApi'
const teacher = {
    namespaced: true,
    state: {
        id: '',
        teacherData: '',
        subjectList: [],
        classList: [],
        deptList: [],
        roleList: [],
        onJobState: [{name: '在职', value: 10}, {name: '退休', value: 11}, {name: '返聘', value: 12}, {name: '借调', value: 13}, {name: '离职', value: 14}]
    },
    getters: {
    },
    mutations: {

    },
    actions: {
        GetClassList ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getClassList(params).then(res => {
                    state.classList = res.items
                })
            })
        },
        GetDept ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getDept(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetSubject ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getSubject(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetTeacherList ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getTeacherList(params).then(res => {
                    resolve(res)
                })
            })
        },
        AddTeacher ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                addTeacher(params).then(res => {
                    resolve(res)
                }).catch(
                    res => {
                        reject(res)
                    }
                )
            })
        },
        GetOneTeacher ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getOneTeacher(params).then(res => {
                    resolve(res)
                })
            })
        },
        EditOneTeacher ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                editOneTeacher(params).then(res => {
                    resolve(res)
                })
            })
        },
        DelOneTeacher ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                delOneTeacher(params).then(res => {
                    resolve(res)
                })
            })
        },
        ImportTeacher ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                importTeacher(params).then(res => {
                    resolve(res)
                }).catch(
                    res => {
                        reject(res)
                    }
                )
            })
        },
        ExportExcel ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                exportExcel(params).then(res => {
                    resolve(res)
                })
            })
        },
        ChangeStatus ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                changeStatus(params).then(res => {
                    resolve(res)
                })
            })
        }
    }
}
export default teacher
